import React, { Component } from 'react'

export class Add extends Component {
  state  = {
    num:0
  }
  // 加1的方法
  add = ()=>{
    this.setState({num:this.state.num+1})
  }
  render() {
    return (
      <div>
        <h1>{this.state.num}</h1>
        <button onClick={this.add}>点击+1</button>
      </div>
    )
  }
}

export default Add